package paywithdrawlogic

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/assets-rpc/internal/dao/model/withdraw"
	"gitee.com/liuxuezhan/ar-platform/assets-rpc/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/assets-rpc/rpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type WithdrawTypeListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewWithdrawTypeListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WithdrawTypeListLogic {
	return &WithdrawTypeListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// -------------------b端提现管理----------------------------------------------------------
func (l *WithdrawTypeListLogic) WithdrawTypeList(in *rpc.GetWithDrawTypeRequest) (*rpc.GetWithDrawTypeResponse, error) {
	m := withdraw.NewTypeModel(l.ctx, l.svcCtx)
	m.WithdrawDailyTimesPre()

	res, err := m.WithdrawTypeList(in)
	// if in.UserId > 0 {
	// 	// 查询用户已提现次数
	// 	userWithrawCount := withdraw.NewWithdrawModel(l.ctx, l.svcCtx).FindUserWithdrawCountMap(in.UserId, time.Now())
	// 	for i := range res.Data {
	// 		if item, ok := userWithrawCount[res.Data[i].Type]; ok {
	// 			res.Data[i].CurTimes -= int32(item)
	// 			if res.Data[i].CurTimes < 0 {
	// 				res.Data[i].CurTimes = 0
	// 			}
	// 		}
	// 	}
	// }

	return res, err
}
